using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.IO;

namespace TemplateCreateTools
{
    public class DataCenter
    {
        private ArrayList ng;
        private ArrayList ok;
        private ArrayList all;
        private string template;

        public DataCenter()
        {
            all = new ArrayList();
            ok = new ArrayList();
            ng = new ArrayList();
        }

        public ArrayList NG
        {
            get
            {
                return ng;
            }
            set
            {
                ng = value;
            }
        }
        public int Count
        {
            get
            {
                return all.Count;
            }
        }
        public ArrayList OK
        {
            get
            {
                return ok;
            }
            set
            {
                ok = value;
            }
        }
        public ArrayList All
        {
            get
            {
                return all;
            }
            set
            {
                all = value;
            }
        }
        public string Template
        {
            get
            {
               return template;
            }
            set
            {
                template = value;
            }
        }
        public void Initialize(string filePath)
        {
            if (Directory.Exists(filePath))
            {
                all.Clear();
                string[] files = Directory.GetFiles(filePath,"*.html");
                foreach (string f in files)
                {
                    SourceItem item = new SourceItem(f);
                    all.Add(item);
                    ng.Add(item);
                }
            }
        }
        public void Judge(string template)
        {
            ng.Clear();
            ok.Clear();
            foreach (SourceItem item in all)
            {
                if (item.Judge(template))
                {
                    ok.Add(item);
                }
                {
                    ng.Add(item);
                }
            }
        }
    }
}
